package com.finace.management.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.entity.PageResult;
import com.entity.Result;
import com.finace.management.service.TbSchoolService;
import com.finace.pojo.TbSchool;
import org.jboss.netty.channel.ExceptionEvent;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("tbschool")
public class TbSchoolController {
//===================================
    @Reference
    private TbSchoolService tbSchoolService;
//列表
    @RequestMapping("list")
    public List<TbSchool> tbschoolfindlist(){
        return tbSchoolService.tbschoolfindlist();
    }

    @RequestMapping("plist")
    public PageResult plist(int pageNum,int pageSize){
        return tbSchoolService.findlist(pageNum,pageSize);
    }
    @RequestMapping("findbyid")
    public TbSchool findbyid(int id){
        return tbSchoolService.findbyid(id);
    }
    @RequestMapping("xiugaistatus")
    public Result xiugaistatus(@RequestBody TbSchool tbSchool){
        try {
            tbSchoolService.xiugaistatus(tbSchool);
            return new Result(true,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"修改失败");
        }

    }

    @RequestMapping("/add")
    public Result add(@RequestBody TbSchool tbSchool){


        try{
            tbSchoolService.add(tbSchool);
            return new Result(true,"成功");
        }catch (Exception e){
            e.printStackTrace();

            return new Result(true,"失败");
        }
    }
    @RequestMapping("/update")
    public Result update(@RequestBody TbSchool tbSchool){
        try {
            tbSchoolService.update(tbSchool);
            return new Result(true,"修改成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,"修改失败");
        }
    }

    @RequestMapping("/findOne")
    public TbSchool findOne(int id){
        return tbSchoolService.findbyid(id);
    }
}
